home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr17 / apcalc10.zip / APCALC.HLP < prev    next >
Text File  |  1993-07-07  |  27KB  |  786 lines

  1. *****************************************************************************
  2.     Arbitrary Precision RPN Calculator
  3.     Copyright (C) 1993 Jason Olasky
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 1, or (at your option)
  8.     any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. *****************************************************************************
  19.  
  20. Arbitrary Precision RPN Calculator, v. 1.0 for DOS
  21.  
  22. written by:
  23.  
  24.       Jason Olasky
  25.       874 New Mark Esplanade
  26.       Rockville, MD 20850
  27.       301-294-9419
  28.       Compuserve [70471,2501]
  29.  
  30. released: July 7, 1993
  31.  
  32. This is an arbitrary precision RPN (reverse polish notation) line oriented
  33. calculator, which includes financial and date functions in addition to many
  34. standard mathematical functions. As I intend to rewrite and expand this as a
  35. Windows application at some future time, the user interface was left fairly
  36. primitive, however the current version should run without any problems in a
  37. DOS window. The extended precision math routines are derived from the Bigcalc
  38. extended precision calculator written by Judson D. McClendon.
  39.  
  40. Virtual arrays are used for the stack and memory registers, so there are no
  41. effective limits on the stack size or number of registers. At present this
  42. probably doesn't matter, but when I add array and matrix operators
  43. it should prove useful. The help function requires Buerg's list.com or other
  44. program named list to be in your path. Pressing F1 will spawn list.com to read
  45. this file, which should be in your current directory.
  46.  
  47. Features of this calculator:
  48.  
  49.    * Arbitrary precision, up to  1075 digits
  50.    * Arbitrary number of decimal places with rounding
  51.    * Fully editable input
  52.    * Recall of up to ten previous input lines
  53.    * Error checking
  54.    * Virtual arrays
  55.    * Pressing F1 spawns list to read this help file
  56.    * Standard financial functions
  57.    * Date functions based on Julian day number
  58.  
  59. The following is a list of the operations currently supported by APCalc:
  60.  
  61.            OPCODE        Function
  62.            ------        --------
  63.             "+",          Add,
  64.             "-",          Subtract,
  65.             "*",          Multiply,
  66.             "/",          Divide,
  67.             "^",          Power,
  68.             "%",          PerCent,
  69.             "\",          Reciprocal,
  70.             "ABS",        AbsoluteValue,
  71.             "SQRT",       SquareRoot,
  72.             "SQR",        Square,
  73.             "FACT",       Factorial,
  74.             "INT",        IntegerPart,
  75.             "FRACT",      FractionPart,
  76.             "MOD",        Modulo,
  77.             "SIN",        Sine,
  78.             "ASIN",       ArcSine,
  79.             "COS",        Cosine,
  80.             "ACOS",       ArcCosine,
  81.             "TAN",        Tangent,
  82.             "ATAN",       ArcTangent,
  83.             "LOG",        Log,
  84.             "EXP10",      Exp10,
  85.             "LN",         Ln,
  86.             "EXPE",       ExpE,
  87.             "PI",         Pi,
  88.             "E",          e,
  89.             "CHS",        ChangeSign,
  90.             "SCI",        SciNotation,
  91.             "FIX",        FixNotation,
  92.             "PREC",       SetPrecision,
  93.             "CLST",       ClearStack,
  94.             "CLRG",       ClearRegisters,
  95.             "CLS",        ClearScreen,
  96.             "STO",        Store,
  97.             "RCL",        Recall,
  98.             "DUP",        Dup,
  99.             "DROP",       Drop,
  100.             "SWAP",       Swap,
  101.             "ROT",        Rot,
  102.             "OVER",       Over,
  103.             "PICK",       Pick,
  104.             "ROLL",       Roll,
  105.             "CLRF",       ClearFin,
  106.             "N",          N,
  107.             "I",          I,
  108.             "PV",         PV,
  109.             "PMT",        PMT,
  110.             "FV",         FV,
  111.             "CF",         CF,
  112.             "PF",         PF,
  113.             "CD",         CD,
  114.             "BE",         BE,
  115.             "JDN",        JDN,
  116.             "DOW",        DayOfTheWeek,
  117.             "DATE",       Date,
  118.             "HMS",        HMS,
  119.             "HRS",        HRS,
  120.             "VIEW",       ViewReg,
  121.             "SHOWS",      ShowStack,
  122.             "STOM",       StoreMultiple,
  123.             "RCLM",       RecallMultiple,
  124.             "QUIT"        Quit
  125.             "EXIT"        Quit
  126.  
  127.  
  128.  
  129. General Notes
  130. -------------
  131.  
  132.  
  133. All opcodes are case insensitive. One character opcodes, i.e. +, -, *, /,
  134. \, ^ , % do not need to be separated from the previous number or operator by
  135. a space, but all other opcodes do. Thus 123 3 4+^ is valid but 123 3STO will be
  136. flagged as an error. Numbers may be preceded by a + or - sign.
  137.  
  138. The stack is based on the forth model rather than the HP calculator model;
  139. that is, the stack expands and contracts as numbers are entered or result
  140. from operations upon numbers already on the stack. As a universal rule, any
  141. operation upon one or more numbers removes those numbers from the stack. To
  142. re-utilize a number, additional copies may be added to the stack with stack
  143. operations or the number may be stored in a register. Certain stack operations
  144. refer to a number on the stack relative to the top of the stack. Thus the
  145. topmost number is stack[0], the nextmost stack[1], etc. See the pick and roll
  146. operations, and shows. The prompt shows the number of elements on the stack.
  147. Thus the prompt 2> indicates that there are two numbers on the stack. If the
  148. stack is non-empty, the number on top of the stack will be displayed before
  149. the prompt. The stack is implemented as a virtual array, so there are no
  150. limits on the number of elements on the stack.
  151.  
  152. There are also an unlimited number of memory registers available as the memory
  153. registers are stored as a virtual array in a disk file. See "Virtual Arrays
  154. in C" by Mark Tichenor, published in the May 1988 issue of Dr. Dobb's Journal.
  155. The downside of this is that some register operations may be slow due to the
  156. need for disk access. The buffers for the stack and registers hold ten elements
  157. each, so if you don't use more than ten stack elements and ten registers,
  158. speed won't be affected.
  159.  
  160. The financial functions utilize the first ten registers, either to save
  161. financial variables or for scratch registers, so if you want to store data
  162. that won't be overwritten by the financial functions, you will need to use
  163. higher numbered registers. Registers are indexed using standard C array
  164. notation, so the first register is reg[0] the second reg[1], etc. The array
  165. index is retrieved from the stack, so to store the number on top of the stack
  166. in register 0, the command would be 0 STO, with the result that the size of
  167. the stack would be reduced by one. To retrieve this number, the command would
  168. be 0 RCL, and the number that was stored in reg[0] would then be the topmost
  169. number on the stack, which has increased in size by 1.
  170.  
  171. The trigonometric functions assume that angles are expressed in radians.
  172.  
  173. The default precision is 18 digits, and the default number of decimal places
  174. for fixed presentation is 2. These may be changed using the prec and fix
  175. operations.
  176.  
  177. The following descriptions of the operations implemented include stack diagrams
  178. showing the effect of the operation on the stack. In these diagrams the topmost
  179. element of the stack is on the right, the elements on the stack are numbered to
  180. indicate the order they were placed on the stack, and the result of the
  181. operation is shown.
  182.  
  183. Standard Mathematical functions
  184. -------------------------------
  185.  
  186. +
  187.  
  188.    Replaces the top two numbers on the stack with their sum.
  189.    n1 n2 --- n1+n2
  190.  
  191. -
  192.  
  193.    Replaces the top two numbers on the stack with their difference .
  194.    n1 n2 --- n1-n2
  195.  
  196. *
  197.  
  198.    Replaces the top two numbers on the stack with their product
  199.    n1 n2 --- n1*n2
  200.  
  201. /
  202.  
  203.    Replaces the top two numbers on the stack with the result of dividing the
  204.    second from the top by the topmost.
  205.    n1 n2 --- n1/n2
  206.  
  207. ^
  208.  
  209.    Replaces the top two numbers on the stack with the result of raising the
  210.    second from the top to the power of the topmost.
  211.    n1 n2 --- n1^n2
  212.  
  213. %
  214.  
  215.    Replaces the top two numbers on the stack with the result of multiplying
  216.    the second from the top by the topmost and then dividing by 100.
  217.    n1 n2 --- n1*n2/100.
  218.  
  219.    Note: To add or subtract a percentage to a number, first duplicate the
  220.    number then calculate the percentage and add or subtract it. Thus to add
  221.    15% to a number use the sequence of operations: dup 15%+
  222.  
  223. \
  224.  
  225.    Replaces the top number on the stack with its inverse.
  226.    n1 --- 1/n1
  227.  
  228. ABS
  229.  
  230.    Replaces the top number on the stack with its absolute value.
  231.    n1 --- abs(n1)
  232.  
  233. SQRT
  234.  
  235.    Replaces the top number on the stack with its square root.
  236.    n1 --- sqrt(n1)
  237.  
  238. SQR
  239.  
  240.    Replaces the top number on the stack with its square.
  241.    n1 --- sqr(n1)
  242.  
  243. FACT
  244.  
  245.    Replaces the top number on the stack with its factorial.
  246.    n1 --- n1!
  247.  
  248. INT
  249.  
  250.    Replaces the top number on the stack with its integer part.
  251.    n1 --- int(n1)
  252.  
  253. FRACT
  254.  
  255.    Replaces the top number on the stack with its fractional part.
  256.    n1 --- fract(n1)
  257.  
  258. MOD
  259.  
  260.    Replaces the top two numbers on the stack with the second from the top
  261.    modulo the topmost.
  262.    n1 n2 --- mod(n1,n2)
  263.  
  264. SIN
  265.  
  266.    Replaces the top number on the stack with its sine.
  267.    n1 --- sin(n1)
  268.  
  269. ASIN
  270.  
  271.    Replaces the top number on the stack with its arcsine.
  272.    n1 --- arcsin(n1)
  273.  
  274. COS
  275.  
  276.    Replaces the top number on the stack with its cosine.
  277.    n1 --- cos(n1)
  278.  
  279. ACOS
  280.  
  281.    Replaces the top number on the stack with its arccosine.
  282.    n1 --- arccos(n1)
  283.  
  284. TAN
  285.  
  286.    Replaces the top number on the stack with its tangent.
  287.    n1 --- tan(n1)
  288.  
  289. ATAN
  290.  
  291.    Replaces the top number on the stack with its arctangent.
  292.    n1 --- arctan(n1)
  293.  
  294. LOG
  295.  
  296.    Replaces the top number on the stack with its logarithm to the base 10.
  297.    n1 --- log10(n1)
  298.  
  299. EXP10
  300.  
  301.    Replaces the top number on the stack with 10 raised to the number.
  302.    n1 --- 10^n1
  303.  
  304. LN
  305.  
  306.    Replaces the top number on the stack with its natural logarithm.
  307.    n1 --- ln(n1)
  308.  
  309. EXPE
  310.  
  311.    Replaces the top number on the stack with e raised to the number.
  312.    n1 --- e^n1
  313.  
  314. PI
  315.  
  316.    Adds pi to the stack.
  317.     --- pi
  318.  
  319. E
  320.  
  321.    Adds e to the stack.
  322.     --- e
  323.  
  324. CHS
  325.  
  326.    Changes the sign of the top number on the stack.
  327.    n1 --- -n1
  328.  
  329. SCI
  330.  
  331.    Does not affect the stack. Numbers will be displayed in scientific notation.
  332.  
  333. FIX
  334.  
  335.    The integer part of the number on top of the stack will be used to set
  336.    the number of decimal places and numbers will be displayed as fixed numbers
  337.    based on the precision and number of decimal places set.
  338.    n1 ---
  339.  
  340. PREC
  341.  
  342.    The integer part of the number on top of the stack will be used to set the
  343.    precision of succeeding calculations. It will not affect results already
  344.    derived. Numbers will be displayed in fixed or scientific format as
  345.    previously set.
  346.    n1 ---
  347.  
  348.  
  349. Stack and Register Operations
  350. -----------------------------
  351.  
  352. CLST
  353.  
  354.    Clears the stack. Clearing the stack sets the stack pointer to 0, but does
  355.    not reduce the number of stack elements that have been created.
  356.    n1 ... nm ---
  357.  
  358. CLRG
  359.  
  360.    Does not affect the stack. Clears all currently allocated registers to zero.
  361.    Initially there are ten registers. Whenever a register is referenced beyond
  362.    the currently allocated registers, additional virtual registers are
  363.    allocated up to and including the new register. Clearing the registers does
  364.    not reduce the number of registers that have been created.
  365.  
  366. STO
  367.  
  368.    Uses the integer part of the number on top of the stack as an index, and
  369.    stores the nextmost number on the stack in the indexed register. If you
  370.    think of the index number as part of the sto command, the effect is really
  371.    to store the number on top of the stack, but from the point of view of the
  372.    stack, the index has briefly been added to the stack.
  373.    n1 n2 ---
  374.  
  375. RCL
  376.  
  377.    Uses the integer part of the number on top of the stack as an index, and
  378.    recalls the number in the indexed register to the stack. Note that unlike
  379.    storing a number which removes the number from the stack, recalling a number
  380.    leaves it in the register. Has the effect of replacing the number on top of
  381.    the stack by the contents of the register indexed by that number.
  382.    n1 --- n2
  383.  
  384. DUP
  385.  
  386.    Adds a copy of the number on top of the stack to the stack.
  387.    n1 -- n1 n1
  388.  
  389. DROP
  390.  
  391.    Deletes the number on top of the stack from the stack.
  392.    n1 ---
  393.  
  394. SWAP
  395.  
  396.    Swaps the two numbers on top of the stack.
  397.    n1 n2 --- n2 n1
  398.  
  399. ROT
  400.  
  401.    Rotates the third from the top of the stack to the top of the stack.
  402.    Equivalent to 2 Roll.
  403.    n1 n2 n3 --- n2 n3 n1
  404.  
  405. OVER
  406.  
  407.    Adds a copy of the second number from the top to the stack.
  408.    n1 n2 -- n1 n2 n1
  409.  
  410.  
  411. PICK
  412.  
  413.    Uses the integer part of the topmost number on the stack to index a
  414.    number on the stack. A copy of the indexed number is added to the stack.
  415.    Like STO, the index number is really part of the pick command, but from the
  416.    point of view of the stack, the index is briefly the top of stack element.
  417.    Indexing for PICK is zero-based, with the top of the stack (index omitted)
  418.    being 0, etc.
  419.    Example: 3 PICK
  420.    n1 n2 n3 n4 3 --- n1 n2 n3 n4 n1
  421.  
  422. ROLL
  423.  
  424.    Uses the integer part of the topmost number on the stack to index a
  425.    number on the stack. The indexed number is removed from the stack and moved
  426.    to the top of the stack, Like STO, the index number is really part of the
  427.    pick command, but from the point of view of the stack, the index is briefly
  428.    the top of stack element. Indexing for ROLL is zero-based, with the top of
  429.    the stack (index omitted) being 0, etc.
  430.    Example: 3 ROLL
  431.    n1 n2 n3 n4 3 --- n2 n3 n4 n1
  432.  
  433.  
  434. Financial Functions
  435. -------------------
  436.  
  437. The financial functions, N, I, PV, PMT, and FV are those first implemented
  438. in the HP-92, as modified for the HP-41 in the PPC ROM. A full explanation
  439. is provided in the PPC ROM User's Manual (1981), from which the algorithm was
  440. derived and the examples taken, as well as in many standard references.
  441.  
  442. The rule for financial calculations using these functions is that money paid
  443. out is considered negative and money received is considered positive in sign.
  444. There are five financial variables. N (number of periods), I (interest rate),
  445. PV (present value), PMT (payment), and FV (future value), and given any three
  446. of them, the other two can be calculated. This calculator includes two
  447. additional parameters, CF, compounding frequency (number of times the interest
  448. rate is compounded during the period for which the interest rate is I%), and
  449. PF, payment frequency (number of payment periods during the period for which
  450. the interest rate is I%). These additional parameters simplify the solution of
  451. some complex financial problems. In addition, there are toggles for beginning
  452. of period/end of period payment and continuous/discrete compounding. The
  453. financial functions either store a number in a register (N - 1, I - 2, PV - 3,
  454. PMT - 4, FV - 5) or calculate that variable based on the other numbers entered,
  455. depending on whether the data entry flag is set. This flag is automatically
  456. set whenever a number is entered or calculated and turned off when a financial
  457. operation is performed. See the examples for details.
  458.  
  459. N
  460.  
  461. Either stores the number of periods in register 1, or calculates N based on
  462. two other values.
  463. n1 --
  464. n1 -- n2
  465.  
  466. I
  467.  
  468. Either stores the interest rate in register 2, or calculates I.
  469. n1 --
  470. n1 -- n2
  471.  
  472. PV
  473.  
  474. Either stores the present value in register 3, or calculates PV.
  475. n1 --
  476. n1 -- n2
  477.  
  478. PMT
  479.  
  480. Either stores the payment in register 4, or calculates PMT.
  481. n1 --
  482. n1 -- n2
  483.  
  484. FV
  485.  
  486. Either stores the future value in register 5, or calculates FV.
  487. n1 --
  488. n1 -- n2
  489.  
  490. CF
  491.  
  492. Sets the compounding frequency.
  493. n1 --
  494.  
  495. PF
  496.  
  497. Sets the payment frequency.
  498. n1 --
  499.  
  500. BE
  501.  
  502. Toggles the beginning/end payment flag.
  503. Does not affect the stack.
  504.  
  505. CD
  506.  
  507. Toggles the continuous/discrete payment flag.
  508. Does not affect the stack.
  509.  
  510. CLRF
  511.  
  512. Clears registers 1 through 5 used for financial variables,
  513. sets CF=PF=1, sets BE to E and CD to D.
  514.  
  515. Examples
  516.  
  517. Monthly payment. A couple purchases a $50,000 house, borrowing $40,000
  518. at 8.5% for 30 years less one month. What is their monthly payment.
  519.  
  520.         clrf 40000 pv 8.5 12/ i 30 12* 1- n pmt
  521.         result is PMT = $307.75
  522.  
  523. Internal rate of return. The couple above then sold their house 18 months
  524. later, netting $25,000. At what annual interest rate would they have had to
  525. invest their original $10,000 and $307.75 monthly payments to obtain $25,000.
  526.  
  527.         clrf 18 n 25000 fv -10000 pv -307.75 pmt i 12*
  528.         result is I = 38.51%
  529.  
  530. Simple interest. Find the annual simple interest rate (%i) for an $800 loan
  531. to be repaid at the end of one year with a single payment of $896.
  532.  
  533.         clrf 1 n -800 pv 896 fv i
  534.         result is APR = 12.0%
  535.  
  536. Compound interest. Find the future value of an $800 loan after one year at a
  537. nominal rate of 12% compounded monthly. No payments are specified, so the
  538. payment frequency is set equal to the compounding frequency.
  539.  
  540.         clrf 12 n 12 dup cf pf 12 i -800 pv fv
  541.         result is FV = 901.46
  542.  
  543. Periodic payment. Find the monthly end of period payment required to fully
  544. amortize the loan in the preceding example. A fully amortized loan has a future
  545. value of zero. Use data retained from preceding example.
  546.  
  547.         0 fv pmt
  548.         result is PMT = $71.08
  549.  
  550. Conventional mortgage. Find the number of monthly payments nexessary to
  551. fully amortize a loan of $100,000 at a nominal rate of 13.25% compounded
  552. monthly, if end of period payments of $1,125,75 are made.
  553.  
  554.         clrf 12 dup cf pf 13.25 i 100000 pv -1125.75 pmt n
  555.         result is N = 360.10
  556.  
  557. Final payment. Using the same data as in the preceding example, find the
  558. amount of the final payment if n is changed to 360. The final payment is
  559. equal to the regular payment plus any balance remaining (FV) at the end of
  560. the last period.
  561.  
  562.         360.0 n fv 4 rcl+
  563.         result is final PMT = $1,234.62
  564.  
  565. Balloon payment. On long term loans, small changes in the periodic payments
  566. can result in large changes in the future value. If the monthly payment in
  567. the preceding example is rounded down to $1,125 what is the additional balloon
  568. payment due with the final payment?
  569.  
  570.         -1125 pmt fv
  571.         result is balloon payment of $3,579.99
  572.  
  573. Canadian mortgage. Find the monthly end-of-period payment necessary to fully
  574. amortize a 25 year $85,000 loan at 11% compounded semiannually.
  575.  
  576.         clrf 2 cf 12 pf 25 12* n 11 i 85000 pv pmt
  577.         result is PMT=818.15
  578.  
  579. European mortgage. The "effective annual rate" (EAR) is used in some European
  580. countries instead of the nominal annual rate commonly used in the US and
  581. Canada. For a 30 year $90,000 mortgage at 14% EAR compute the monthly end-of-
  582. period payments, noting that when using an EAR, the compounding frequency is
  583. set to 1.
  584.  
  585.         clrf 12 pf 360 n 14 i 90000 pv pmt
  586.         result is PMT=$1,007.88
  587.  
  588. Bi-weekly savings. Compute the future value of bi-weekly savings of $100 for
  589. three years at a nominal annual rate of 5.5% compounded daily. Note that
  590. it is necessary to toggle the BE flag to beginning of period.
  591.  
  592.         clrf be 365 cf 26 dup pf 3* n 5.5 i -100 pmt fv
  593.         result is FV=$8,489.32
  594.  
  595. Present value of an annuity. What is the present value of $500 to be received
  596. at the beginning of each quarter over a 10 year period if money is being
  597. discounted at a 10% nominal annual rate compounded monthly. Note that it
  598. is necessary to toggle the BE flag.
  599.  
  600.         clrf be 12 cf 4 dup pf 10* n 10 i 500 pmt pv
  601.         result is PV=$12,822.64
  602.  
  603. Balloon payment. Compute the monthly end-of-period payment on a 3 year
  604. $20,000 loan at 15% nominal annual rate compounded monthly, with a $10,000
  605. balloon payment due at the end of the 37th period. Note that the balloon
  606. payment must be discounted one period to make it coincide with the last
  607. regular payment.
  608.  
  609.         clrf 12 dup dup cf pf 3* n 15 i 20000 pv pmt
  610.         at this point the effective monthly interest rate as a decimal is in
  611.         register 6; throw away the number on the stack (monthly pmt without
  612.         the balloon) and continue as follows:  drop -10000 6 rcl 1+ / fv pmt
  613.         result is PMT=474.39
  614.  
  615. Effective rate using a 365/360 basis. Compute the effective annual rate (%APR)
  616. for a nominal annual rate of 12% compounded on a 365/350 basis.
  617.  
  618.         clrf 3 fix 365 dup n cf 360 pf 12 i -100 pv fv 3 rcl +
  619.         result is APR=12.935%
  620.  
  621. Mortgage with points. What is the true APR of a 30 year, $75,000 loan at a
  622. nominal rate of 13.25% compounded monthly, with monthly end-of-period payments
  623. of $844.33 if 3 points are charged? The PV must be reduced by the dollar value
  624. of the points  to establish an effective PV. Because the payments remain the same,
  625. the true APR will be higher than the nominal rate.
  626.  
  627.         clrf 12 dup dup cf pf 30* n 75000 dup 3% - pv -844.33 pmt i
  628.         result is APR=13.69%
  629.  
  630. Equivalent payments. Find the equivalent monthly payment required to amortize
  631. a 20 year $40,000 loan at 10.5% nominal annual rate compounded monthly, with
  632. ten annual payments of $5,029.71 remaining. Compute the PV of the remaining
  633. annual payments then change n and PF to a monthly basis and compute the equivalent
  634. monthly payment.
  635.  
  636.         clrf 12 cf 10 n 10.5 i -5029.71 pmt pv
  637.         PV of remaining payments is $29,595.88
  638.         12 dup pf 10* n pmt
  639.         result is monthly PMT=$399.35
  640.  
  641. Perpetuity with continuous compounding. If you can purchase a single payment
  642. annuity with an initial investment of $60,000 that will be invested at a 15%
  643. nominal annual rate compounded continuously, what is the maximum monthly
  644. return you can receive without reducing the principal. If the interest rate
  645. is constant and the principal is not disturbed the payments can go on
  646. indefinitely. Note that the term n of a perpetuity is immaterial and can
  647. be set to any non-zero value.
  648.  
  649.         clrf cd 12 dup pf n 15 i 60000 dup fv -1* pv pmt
  650.         result is PMT=$754.71
  651.  
  652.  
  653. Calendar and Time Functions
  654. ---------------------------
  655.  
  656. The calendar functions JDN and Date are inverses. JDN computes the Julian Day
  657. Number for a given calendar date and date converts a JDN to a calendar date.
  658. The valid range for dates is from March 1 of the year 0 CE (Common Era, also
  659. known as AD) to sometime in the far future. All dates are assumed to follow
  660. the Gregorian calendar, which may cause problems for dates before the Gregorian
  661. calendar was adopted, 1582 when originally devised, adopted in 1752 by the
  662. British Empire including the then American colonies, as late as 1927 for Turkey.
  663. It is possible to use a more complicated algorithm to allow for dates in either
  664. the Gregorian or the Julian calendars, and including dates BCE (Before the
  665. Common Era, also known as BC) but this program does not do so at present.
  666.  
  667. The Julian Day Number should not be confused with the Julian Calendar. The
  668. Julian Day Number is the number of whole days that have elapsed since a certain
  669. reference time in the past. The JDN is widely used in astronomy and elsewhere
  670. in calculations involving dates. The reference time is January 1, 4713 BCE,
  671. Julian Calendar, at noon.
  672.  
  673. It should be noted that the day of the week corresponding to a given date can
  674. be easily calculated given the JDN. The day of the week is (JDN + 1) MOD 7,
  675. where 0 = Sunday, 1 = Monday, etc.
  676.  
  677. JDN
  678.  
  679. Converts a calendar date in the form YYYY.MMDD to the corresponding JDN.
  680. n1 --- n1
  681.  
  682. DOW
  683.  
  684. Displays the day of the week corresponding to the julian day number on the
  685. stack.
  686. n1 ---
  687.  
  688. DATE
  689.  
  690. Converts a JDN to a calendar date in the form YYYY.MMDD
  691. n1 --- n2
  692.  
  693.  
  694. Examples
  695.  
  696. The attack on Pearl Harbor occured on December 7, 1941. What day of the week
  697. was it?
  698.  
  699.         1941.1207 jdn dow
  700.         result is Sunday
  701.  
  702. What day of the year is July 4, 1993?
  703.  
  704.         1993.0704 jdn 1992.1231 jdn -
  705.         result is  July 4, 1993 is the 185th day of the year
  706.  
  707. What day is 85 days after July 4, 1993?
  708.  
  709.         4 fix 1993.0704 jdn 85+ date
  710.         result is 1993.0927 or September 27
  711.  
  712.  
  713. The time functions HMS and HRS allow converting between times expressed as
  714. decimal numbers and times expressed as hours, minutes, seconds. The time
  715. functions have precision only to the hundredth of a second.
  716.  
  717. HMS
  718.  
  719. Converts time expressed as a decimal number H.DDDDDD to H.MMSSCC, where H is
  720. hours, DDDDDD is some fraction of an hour, MM is minutes, SS is seconds, and
  721. CC is hundredths of a second. Result is rounded to CC.
  722. H.DDDDDDDD --- H.MMSSCC
  723.  
  724. HRS
  725.  
  726. Converts a time expressed as H.MMSSCC to H.DDDDDD
  727. H.MMSSCC --- H.DDDDDD
  728.  
  729.  
  730. Miscellaneous Operations
  731. ------------------------
  732.  
  733. CLS
  734.  
  735. Clears the screen. Does not affect the stack.
  736.  
  737. VIEW
  738.  
  739. Displays selected registers based on the block control word bbb.eeeii
  740. where bbb is the first register to view, eee is the last register to view,
  741. and ii is the increment.
  742. bbb.eeeii ---
  743.  
  744. SHOWS
  745.  
  746. Displays the stack from top to bottom. the stack is not affected.
  747.  
  748. STOM
  749.  
  750. Stores the contents of the stack based on the block control word. Starts
  751. with the top element on the stack not counting the block control word and
  752. continues until done.
  753. n1 n2 ... nm bbb.eeeii ---
  754.  
  755. RCLM
  756.  
  757. Recalls the contents of a block of registers to the stack based on the block
  758. control word. Starts with the last register in the block and decrements to
  759. restore the stack in the same order it was originally.
  760. bbb.eeeii --- n1 n2 ... nm
  761.  
  762. QUIT or EXIT
  763. terminates the program
  764.  
  765. -----------------------------------------------------------------------------
  766.  
  767. Usage of this program is free, in accordance with the Free Software Foundation
  768. policy. Source code is available, as indicated below.
  769.  
  770. Portions of this code were derived from the following sources:
  771.  
  772. Bigcalc version 4.4 by Judson D. McClendon
  773. Parser by LLoyd Zusman
  774. Editstr by Bob Bybee
  775. Varray by Mark Tichenor
  776. Vid_Scrn by Jerry Joplin
  777. Exec by Thomas Wagner
  778.  
  779. For a copy of the source code, send $10 to
  780.  
  781.       Jason Olasky
  782.       874 New Mark Esplanade
  783.       Rockville, MD 20850
  784.  
  785. Notifications of bugs or comments in general are welcome.
  786.